import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import Login from '@/views/Login/index.vue'
import NotFind from '@/views/Error/404.vue'
import NoAuth from '@/views/Error/401.vue'
import { setGuard } from './guard'

export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'Login',
    component: Login,
    meta: {
      hidden: true,
      title: '登录',
    },
  },
  {
    path: '/401',
    name: 'NoAuth',
    component: NoAuth,
    meta: {
      title: '401',
      hidden: true,
    },
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'not-found',
    component: NotFind,
    meta: {
      title: '404',
      hidden: true,
    },
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [...constantRoutes],
})

setGuard(router)
export default router
